apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: alerting-executor
  name: alerting-executor
  namespace: kubesphere-alerting-system
spec:
  replicas: 1
  selector:
    matchLabels:
      app: alerting-executor
  template:
    metadata:
      labels:
        app: alerting-executor
    spec:
      initContainers:
      - name: wait-mysql
        image: {{ busybox_repo }}:{{ busybox_tag }}
        imagePullPolicy: IfNotPresent
        command: ['sh', '-c', 'until nc -z {{ dbHost }} {{ dbPort }}; do echo "waiting for mysql"; sleep 2; done;']
      - name: wait-etcd
        image: {{ busybox_repo }}:{{ busybox_tag }}
        imagePullPolicy: IfNotPresent
        command: ['sh', '-c', 'until nc -z {{ etcdHost }} {{ etcdPort }}; do echo "waiting for etcd"; sleep 2; done;']
      containers:
      - command:
        - /alerting/adapter
        image: {{ ks_alerting_adapter_repo }}:{{ ks_alerting_adapter_tag }}
        imagePullPolicy: {{ ks_image_pull_policy }}
        name: alerting-adapter
        env:
        - name: ADAPTER_APP_MONITORING_HOST
          value: "http://ks-apiserver.kubesphere-system.svc/kapis/monitoring.kubesphere.io/v1alpha2"
        resources:
          limits:
            cpu: "1"
            memory: 500Mi
          requests:
            cpu: 10m
            memory: 10Mi
      - command:
        - /alerting/alert
        image: {{ ks_alerting_repo }}:{{ ks_alerting_tag }}
        imagePullPolicy: {{ ks_image_pull_policy }}
        name: alerting-executor
        env:
        - name: ALERT_APP_RUN_MODE
          value: "executor"
        - name: ALERT_MYSQL_HOST
          value: "{{ dbHost }}"
        - name: ALERT_ETCD_ENDPOINTS
          value: "{{ etcdEndpoint }}"
        - name: ALERT_APP_MONITORING_HOST
          value: "http://ks-apiserver.kubesphere-system.svc/kapis/monitoring.kubesphere.io/v1alpha2"
        - name: ALERT_QUEUE_TYPE
          value: "redis"
        - name: ALERT_QUEUE_ADDR
          value: "redis://{{ redisEndpoint }}"
        - name: ALERT_APP_NOTIFICATION_HOST
          value: "notification.kubesphere-alerting-system.svc:9201"
        - name: ALERT_LOG_LEVEL
          value: "info"
        - name: ALERT_MYSQL_LOG_MODE
          value: "false"
        resources:
          limits:
            cpu: "2"
            memory: 2000Mi
          requests:
            cpu: 10m
            memory: 10Mi
